FROM golang:1.14-alpine as builder

# privaite repo go module
RUN apk add --no-cache git
ARG	GITEE_USER
ARG	GITEE_TOKEN
RUN echo "machine gitee.com login ${GITEE_USER} password ${GITEE_TOKEN}" > ~/.netrc

WORKDIR /cdce-service
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o build/service ./cmd/service/

FROM alpine
COPY --from=builder /cdce-service/build/ /
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/service"]
